﻿using System.Collections.Generic;
using GraphProcessor;
using IQIGame.Onigao.Logic;
using LFloatMath.Math;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(SkillEditorConst.SkillEffective + "/" + SkillEditorConst.Impact, typeof(SkillEditorGraph))]
    public class SkillEffectiveNode_Impact : SkillEffectiveNode
    {
        protected override ESkillEffectiveType effectType => ESkillEffectiveType.Impact;

        public float maxLength;
        public float speed = 5;
        public int checkNum = 1; // 射线检测精度，默认是1 除了中间外，左右各需要检测几条
        public ETargetRelation targetRelation;
        [Output("效果节点", false)] public SkillEditorActionNode actions;

        protected override void Process()
        {
            base.Process();
            this.actions = new SkillEditorActionNode()
            {
                setter = (x) =>
                {
                    (this.selfConfig.customConfig as SkillEffective_Impact_ConfigData)?.actions.Add(x);
                }
            };
        }

        protected override SkillCustomConfig CreateConfig()
        {
            var rConfig = new SkillEffective_Impact_ConfigData()
            {
                checkNum = this.checkNum,
                maxLength = this.maxLength.ToLFloat()._val,
                speed = this.speed.ToLFloat()._val,
                targetRelation = (int)this.targetRelation,
                actions = new List<SkillActionNode>(),
            };
            return rConfig;
        }
    }
}